using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace Terra.Data.Entities.Logging;

/// <summary>
/// 请求日志实体
/// </summary>
[Table("RequestLogs")]
[Comment("请求日志表")]
[Index(nameof(RequestPath))]
[Index(nameof(RequestTime))]
public class RequestLog : LogEntityBase
{
    /// <summary>
    /// 请求路径
    /// </summary>
    [Required]
    [MaxLength(256)]
    [Comment("请求路径")]
    public string RequestPath { get; set; }

    /// <summary>
    /// 请求方法
    /// </summary>
    [Required]
    [MaxLength(32)]
    [Comment("HTTP请求方法：GET、POST等")]
    public string HttpMethod { get; set; }

    /// <summary>
    /// 请求时间
    /// </summary>
    [Required]
    [Comment("请求发生时间")]
    public DateTime RequestTime { get; set; }

    /// <summary>
    /// 响应时间(ms)
    /// </summary>
    [Comment("请求响应时间(毫秒)")]
    public long ResponseTime { get; set; }

    /// <summary>
    /// 状态码
    /// </summary>
    [Required]
    [Comment("HTTP状态码")]
    public int StatusCode { get; set; }

    /// <summary>
    /// 请求头
    /// </summary>
    [Comment("请求头JSON")]
    public string RequestHeaders { get; set; }

    /// <summary>
    /// 请求体
    /// </summary>
    [Comment("请求体")]
    public string RequestBody { get; set; }
}